<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Retrieve a item</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.yaconf.html">« Yaconf</a></li>
      <li style="float: right;"><a href="yaconf.has.html">Yaconf::has »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.yaconf.html">Yaconf</a></li>
    <li>Retrieve a item</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="yaconf.get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaconf::get</h1>
  <p class="verinfo">(PECL yaconf &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Yaconf::get</span> &mdash; <span class="dc-title">Retrieve a item</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaconf.get-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>Yaconf::get</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$default_value</code><span class="initializer"> = NULL</span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">

  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaconf.get-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">name</code></dt>

    <dd>

     <p class="para">
      Configuration key, the key looks like &quot;filename.key&quot;, or &quot;filename.sectionName,key&quot;.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">default_value</code></dt>

    <dd>

     <p class="para">
      if the key doesn&#039;t exists, Yaconf::get will return this as result.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaconf.get-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns configuration result(string or array) if the key exists,
   return default_value if not.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaconf.get-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3949">
   <p><strong>示例 #1 <span class="function"><strong>INI()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="inicode"><pre class="inicode">;filenmame foo.ini, placed in directory which is yaconf.directoy
[SectionA]
;key value pair
key=val
;hash[a]=val
hash.a=val
;arr[0]=val
arr.0=val
;or
arr[]=val

;SectionB inherits SectionA
[SectionB:SectionA]
;override configuration key in SectionA
key=new_val</pre>
</div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
php7 -r &#039;var_dump(Yaconf::get(&quot;foo.SectionA.key&quot;));&#039;
//string(3) &quot;val&quot;

php7 -r &#039;var_dump(Yaconf::get(&quot;foo.SectionB.key&quot;));&#039;
//string(7) &quot;new_val&quot;

php7 -r &#039;var_dump(Yaconf::get(&quot;foo&quot;)[&quot;SectionA&quot;][&quot;hash&quot;]);&#039;
//array(1)

</pre></div>
   </div>
  </div>
 </div>


</div></div></div></body></html>